package com.itlong.cloud.operate.service.impl;

import com.itlong.cloud.POJO.PO.OperateSceneUserTypePO;
import com.itlong.cloud.PlatformConstants;
import com.itlong.cloud.operate.dao.IOperateSceneUserTypeDao;
import com.itlong.cloud.operate.service.IOperateSceneUserTypeService;
import com.itlong.cloud.thrown.DataAccessException;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 * 场景人员类型管理接口实现
 * </desc>
 *
 * @createDate 2021-03-25
 */
@Service
public class OperateSceneUserTypeServiceImpl implements IOperateSceneUserTypeService {

    @Autowired
    private IOperateSceneUserTypeDao iOperateSceneUserTypeDao;

    /**
     * <desc>
     * 添加人员类型
     * <desc/>
     *
     * @param m 添加人员类型
     * @return
     * @author zhouchun
     * @createDate 2021-03-25
     */
    @Override
    public Integer save(OperateSceneUserTypePO m) throws Exception {
        Map<String, Object> params = SqlUtil.durableData(m, PlatformConstants.TABLE_SAVE);
        Integer res = iOperateSceneUserTypeDao.save(params);
        if (res <= 0) {
            throw new DataAccessException("【创建场景人员类型失败】");
        }
        return res;
    }

    @Override
    public Integer update(OperateSceneUserTypePO m) {
        return iOperateSceneUserTypeDao.update(m);
    }

    @Override
    public List<OperateSceneUserTypePO> getListByIds(String ids) {
        return iOperateSceneUserTypeDao.getListByIds(ids);
    }

    @Override
    public OperateSceneUserTypePO getOneByUserTypeId(String userTypeId) {
        return iOperateSceneUserTypeDao.getOneByUserTypeId(userTypeId);
    }

    @Override
    public Integer deleteByUserTypeIdsNotIn(String sceneId, String userTypeIds) {
        return iOperateSceneUserTypeDao.deleteByUserTypeIdsNotIn(sceneId, userTypeIds);
    }

}